package com.san.hkhospital.service.impl;

import com.san.hkhospital.vo.Search;
import com.san.hkhospital.vo.hospitalizedTableVo;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import com.san.hkhospital.mapper.HospitalizedMapper;
import com.san.hkhospital.entity.HospitalizedExample;
import com.san.hkhospital.entity.Hospitalized;
import com.san.hkhospital.service.HospitalizedService;
import org.springframework.transaction.annotation.Transactional;

/**
 * ClassName:HospitalizedServiceImpl
 * PackageName:com.san.hkhospital.service.impl
 * Description:
 *
 * @Author:yy
 * @CreatedAt:2024/11/13 14:38
 * 
 */
 
 
@Service
@Transactional
public class HospitalizedServiceImpl implements HospitalizedService{

    @Resource
    private HospitalizedMapper hospitalizedMapper;

    @Override
    public long countByExample(HospitalizedExample example) {
        return hospitalizedMapper.countByExample(example);
    }

    @Override
    public int deleteByExample(HospitalizedExample example) {
        return hospitalizedMapper.deleteByExample(example);
    }

    @Override
    public int deleteByPrimaryKey(Integer hpdId) {
        return hospitalizedMapper.deleteByPrimaryKey(hpdId);
    }

    @Override
    public int insert(Hospitalized record) {
        return hospitalizedMapper.insert(record);
    }

    @Override
    public int insertSelective(Hospitalized record) {
        return hospitalizedMapper.insertSelective(record);
    }

    @Override
    public List<Hospitalized> selectByExample(HospitalizedExample example) {
        return hospitalizedMapper.selectByExample(example);
    }

    @Override
    public Hospitalized selectByPrimaryKey(Integer hpdId) {
        return hospitalizedMapper.selectByPrimaryKey(hpdId);
    }

    @Override
    public int updateByExampleSelective(Hospitalized record,HospitalizedExample example) {
        return hospitalizedMapper.updateByExampleSelective(record,example);
    }

    @Override
    public int updateByExample(Hospitalized record,HospitalizedExample example) {
        return hospitalizedMapper.updateByExample(record,example);
    }

    @Override
    public int updateByPrimaryKeySelective(Hospitalized record) {
        return hospitalizedMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(Hospitalized record) {
        return hospitalizedMapper.updateByPrimaryKey(record);
    }

    @Override
    public Hospitalized find(Integer hpdId) {
        return hospitalizedMapper.selectByPrimaryKey(hpdId);
    }

    @Override
    public List<hospitalizedTableVo> findAll() {
        return hospitalizedMapper.findAll();
    }

    @Override
    public boolean add(Hospitalized hospitalized) {
        int i = hospitalizedMapper.insert(hospitalized);
        return i>0?true:false;
    }

    @Override
    public boolean update(Hospitalized hospitalized) {
        int i = hospitalizedMapper.updateByPrimaryKeySelective(hospitalized);
        return  i>0?true:false;
    }

    @Override
    public List<hospitalizedTableVo> search(Search search) {
        return hospitalizedMapper.search(search);
    }

    @Override
    public boolean chuyuanKai(Integer hpdId) {
        Hospitalized hospitalized = new Hospitalized();
        hospitalized.setHpdId(hpdId);
        hospitalized.setHpdStartTime(new Date());
        int i = hospitalizedMapper.updateByPrimaryKeySelective(hospitalized);
        return i>0?true:false;
    }

    @Override
    public boolean chuyuanJie(Integer hpdId) {
        Hospitalized hospitalized = new Hospitalized();
        hospitalized.setHpdId(hpdId);
        hospitalized.setHpdEndTime(new Date());
        int i = hospitalizedMapper.updateByPrimaryKeySelective(hospitalized);
        return i>0?true:false;
    }



}
